package com.bytz.modules.cms.domain.util;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * 价格计算帮助类
 * @author shanxuezhong
 */
public class PriceComputerUtil {

    /**
     * 保留4位小数
     */
    public static BigDecimal scale(BigDecimal op1) {
        return op1.setScale(4, RoundingMode.HALF_UP);
    }

    public static BigDecimal saveScale(BigDecimal op1) {
        return op1.setScale(2, RoundingMode.HALF_UP);
    }

    /**
     * 除，保留4位小数
     */
    public static BigDecimal divide(BigDecimal op1, BigDecimal op2) {
        return op1.divide(op2, 4, RoundingMode.HALF_UP);
    }
}
